package com.itheima.homework;

import com.itheima.homework.domain.Student;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class MethodDemo {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException {
        Class clazz = Class.forName("com.itheima.homework.domain.Student");
        Method student1 = clazz.getDeclaredMethod("study",String.class);
        Student student = (Student) clazz.newInstance();
        student1.invoke(student,"数学");
        Method study = clazz.getDeclaredMethod("study");
        study.setAccessible(true);
        study.invoke(student);
    }
}
